import Vue from "vue";
import VueRouter from "vue-router";
const Home = () => import("../views/Home/Home.vue");
const Book = () => import("../views/Book/Book.vue");
const Publish = () => import("../views/Publish/Publish.vue");
const Area = () => import("../views/Publish/Area.vue");
const Mine = () => import("../views/Mine/Mine.vue");
const Layout = () => import("../views/Layout/Layout.vue");
const Rent = () => import("../views/Mine/Rent.vue");
const Rented = () => import("../views/Mine/Rented.vue");
const Notice = () => import("../views/Mine/Notice.vue");
const Custmer = () => import("../views/Mine/Custmer.vue");
const Record = () => import("../views/Mine/Record.vue");
const Serve = () => import("../views/Mine/Serve.vue");
Vue.use(VueRouter);

const routes = [
  {
    redirect: "/home",
    path: "/",
    meta: {
      title: "爱阅之城",
    },
    component: Layout,
    children: [
      {
        path: "/home",
        component: Home,
        meta: {
          title: "爱阅之城",
        },
      },
      {
        path: "/publish",
        component: Publish,
        meta: {
          title: "爱阅之城",
        },
      },
      {
        path: "/mine",
        component: Mine,
        meta: {
          title: "爱阅之城",
        },
      },
      {
        path: "/cumster",
        component: Custmer,
        meta: {
          title: "爱阅之城",
        },
      },
    ],
  },
  {
    name: Book,
    path: "/book",
    component: Book,
    meta: {
      title: "爱阅之城",
    },
  },
  {
    path: "/notice",
    component: Notice,
    meta: {
      title: "爱阅之城",
    },
  },
  {
    path: "/rent",
    component: Rent,
    meta: {
      title: "爱阅之城",
    },
  },
  {
    path: "/rented",
    component: Rented,
    meta: {
      title: "爱阅之城",
    },
  },
  {
    path: "/record",
    component: Record,
    meta: {
      title: "爱阅之城",
    },
  },
  {
    path: "/serve",
    component: Serve,
    meta: {
      title: "爱阅之城",
    },
  },
  {
    path: "/area",
    component: Area,
    meta: {
      title: "爱阅之城",
    },
  },
];

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes,
});
// 路由导航守卫;

// router.beforeEach((to, from, next) => {
//   if (
//     (window.location =
//       "https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=ayzctctsgxxt")
//   ) {
//     console.log("进入书城");
//     return next();
//   }
//   //当访问的页面不是登录页面的时候请求需要校验
//   //获取token数据
//   let token = window.sessionStorage.getItem("token");

//   if (token !== null && token.length > 0)
//     if (token) {
//       return next();
//     }
//   next("/cumster");
// });
export default router;
